<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath+"policy/"%>"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>新增保单</title>
<link href="../style/main.css" rel="stylesheet" type="text/css" />
<link type="text/css" rel="stylesheet"  href="../style/style.css" />
<style>
body{ padding:10px}
</style>
<script type="text/javascript" src="../Scripts/jquery.js"></script>
<script type="text/javascript">
function changeCompany(){
	var companyList =  document.getElementById("company");
	var companyNum = companyList.options[companyList.selectedIndex].value;
	if(companyNum == "")
		return;
	$.post("/WITAgent/Product/findSubcompanyByCompanyAction.action",{companyNum:companyNum},function(data){
		var subcompanyList = document.getElementById("subcompany");
		while(subcompanyList.options.length > 0){
			subcompanyList.remove(0);
		}
		var op = document.createElement("option");
            op.value = "";
            op.text = "--全部--";
            subcompanyList.options.add(op);
		for(var i=0;i<data.length;i++){
            op = document.createElement("option");
            op.value = data[i].insuranceNumber;
            op.text = data[i].insuranceName;
            subcompanyList.options.add(op);
        }
	},"json");
}

function changeSubcompany(){
	var subcompanyList =  document.getElementById("subcompany");
	var subcompanyNum = subcompanyList.options[subcompanyList.selectedIndex].value;
	var insuranceNum = document.getElementById("insuranceNum").value;
	if(subcompanyNum == "")
		return;
	$.post("/WITAgent/Product/insurancedefAction!findInsurancedefBySubcompInsurance.action",{subcompanyId:subcompanyNum,insuranceNumber:insuranceNum},function(data){
		document.getElementById("insurancedef").value=data.insuranceId;
		document.getElementById("insuranceNumMark").value=data.insuranceNumMark;
		document.getElementById("discountrate").value=data.discountrate;
		document.getElementById("agencyrate").value=data.agencyrate;
		document.getElementById("commrate").value=data.commrate;
		document.getElementById("specificalagree").value=data.specificalagree;
		var pros = data.projectList;
		var ls_t=document.getElementById("projects");
		while(ls_t.rows.length > 1){
			ls_t.deleteRow(1);
		}
		alert("finished delete");
		for(var i = 0; i < pros.length; i ++){
		var newRow = "<tr align='center'>"+"<td>"+pros[i].projectNum+"</td>"+"<td>"+pros[i].projectName+"</td>"+"<td>"+pros[i].insurancerate+"</td>"+"<td>"+pros[i].flag+"</td>"+"<tr>";
		$(ls_t).append(newRow);
		
		}
		document.getElementById("nextpage").href=document.getElementById("nextpage").href+"?insuranceId="+data.insuranceId;
	},"json");
}
</script>
</head>

<body>
<div class="search">
<table width="100%" border="0" align="left" cellpadding="0" cellspacing="0" class="table">
  <tr>
    <td><div class="mainarea">
      <div class="search">
      
      <s:form action="insurancedefAction!findInsurancedefBySubcompInsurance" method="post" theme="simple">
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table4">
          <tr>
            <td width="28%" colspan="2" bgcolor="#BBD2F7" class="title">险种资料</td>
          </tr>
          <tr>
            <td height="818" colspan="2">
            <table width="100%" border="0" cellspacing="2" cellpadding="0">
              
              <tr>
                <td width="23%" align="right" >险种编号：</td>
                <td colspan="3" align="left" ><input type="hidden" value="<s:property value='insurancedef.insuranceId'/>" id="insurancedef"/><s:textfield name="insurancedef.insurancetype.insuranceNumber" id="insuranceNum" cssStyle="width:138px"/></td>
              </tr>
              <tr>
                <td align="right" >险种名称：</td>
                <td colspan="3" align="left" ><s:textfield id="insuranceName" cssStyle="width:138px" /></td>
              </tr>
              <tr>
                <td align="right" >保险公司：</td>
                <td colspan="3" align="left" ><s:select id="company" headerKey="''" headerValue="--全部--" list="companyList" listKey="companyNum" listValue="shortName" cssStyle="width:150px" onchange="changeCompany()">
                </s:select></td>
              </tr>
              <tr>
                <td align="right" >分支公司：</td>
                <td colspan="3" align="left" ><s:select list="#{}" name="insurancedef.subcompany.subcompanyId" cssStyle="width:150px" id="subcompany" onchange="changeSubcompany()">
			</s:select></td>
              </tr>
              <tr>
                <td align="right" >保险编号标识：</td>
                <td width="27%" align="left" ><s:textfield name="insurancedef.insuranceNumMark"  cssStyle="width:138px" id="insuranceNumMark"/></td>
                <td align="right" >折扣系数：</td>
                <td align="left" ><s:textfield name="insurancedef.discountrate" id="discountrate"  cssStyle="width:138px"/></td>
              </tr>
              
              <tr>
                <td align="right" >代理费比例：</td>
                <td align="left" ><s:textfield name="insurancedef.agencyrate" id="agencyrate"  cssStyle="width:138px"/></td>
                <td width="15%" align="right" >佣金比例：</td>
                <td width="35%" align="left" ><s:textfield name="insurancedef.commrate" id="commrate"  cssStyle="width:138px"/></td>
              </tr>
              <tr>
                <td align="right" >特别约定：</td>
                <td colspan="3" align="left" ><s:textfield name="insurancedef.specificalagree" cssStyle="width:300px" id="specificalagree"/></td>
              </tr>
              <tr>
                <td align="right" >标的类别 ：</td>
                <td><s:textfield name="mark" cssStyle="width:300px" id="markName"/></td>
                <td width="15%" align="right">&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
            </table>
              </td>
          </tr>
        </table>
        </s:form>
        
        <table width="100%" cellpadding="0" cellspacing="1"  class="table4" id="projects">
        <tr bgcolor="#BBD2F7">
                <th>项目编号</th>
                <th>项目名称</th>
                <th>保险费率</th>
                <th>是否主险</th>
                </tr>
            </table>
     
        </div>
    </div></td>
  </tr>
</table>
<div class="clear"></div>
<table width="100%" align="left" cellpadding="0" cellspacing="0" class="table3"  style="margin-top:10px">
<tr>
<td align="center" ><span class="clientinfo_but"><a href="right_Policy_2.jsp" id="nextpage">下一步</a></span></td>
</tr>
</table>
</div>
</body>
</html>